﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Media;

namespace DataLayer
{
    public class ErrorsHelper : SystemFileHelper
    {
        public override List<SystemFile> LoadAll()
        {
            List<SystemFile> listWindows = new List<SystemFile>();
            XmlDocument document = new XmlDocument();
            XmlTextReader reader = new XmlTextReader("./SystemFile/Error.xml");
            reader.Read();
            // load reader
            document.Load(reader);

            for (int i = 0; i < document.ChildNodes[0].ChildNodes[0].ChildNodes.Count; i++)
            {
                MyWindow win = new MyWindow();
                XmlNode currentNode = document.ChildNodes[0].ChildNodes[0].ChildNodes[i];
                win.ContentId=int.Parse(currentNode.SelectSingleNode("Content").InnerText);
                win.FocusId= int.Parse(currentNode.SelectSingleNode("FocusID").InnerText);
                win.Height =int.Parse( currentNode.SelectSingleNode("Size").Attributes["h"].Value);
                win.Width = int.Parse(currentNode.SelectSingleNode("Size").Attributes["w"].Value);
                win.Status = bool.Parse(currentNode.SelectSingleNode("Status").InnerText);
                win.Position = int.Parse(currentNode.SelectSingleNode("Position").InnerText);
                listWindows.Add(win);
            }
            return listWindows;
        }

        public override void Update(SystemFile sysFile)
        {
            base.Update(sysFile);
        }
    }
}
